<include file="Common/header-control" xmlns="http://www.w3.org/1999/html" />
<div class="row">
    <div class="col-md-12">
        <ul class="nav nav-tabs">
            <li class="active"><a href="{:U('control/member/groups')}">会员组</a></li>
        </ul>
    </div>
    <div class="box col-md-12">
        <div class="box-inner">
            <div class="box-header well" data-original-title="">
                <h2><i class="fa fa-list"></i> <a name="result"></a>所有会员组</h2>
            </div>
            <div class="box-content">
                <form action="" method="post">
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <tr>
                                <th style="min-width:100px;">会员组</th>
                                <th style="min-width:400px;">说明</th>
                                <th style="min-width:80px;">默认组</th>
                                <th style="min-width:60px;">排序</th>
                                <th style="min-width:160px;"></th>
                            </tr>
                            <foreach name="groups" item="group">
                                <tr>
                                    <td>
                                        {$group['title']}
                                    </td>
                                    <td>
                                        {$group['remark']}
                                    </td>
                                    <td>
                                        <div class="radio">
                                            <label>
                                                <if condition="$group['isdefault']">
                                                    <input name="default" value="{$group['id']}" type="radio" checked> 设为默认
                                                    <else/>
                                                    <input name="default" value="{$group['id']}" type="radio"> 设为默认
                                                </if>
                                            </label>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="row">
                                            <div class="col-sm-4">
                                                <input class="form-control" type="text" name="orderlist[{$group['id']}]" value="{$group['orderlist']}" />
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <if condition="empty($group['issystem'])">
                                            <div class="btn-group btn-group-sm">
                                                <a class="btn btn-default" href="{:U('control/member/groups?id=' . $group['id'])}">编辑</a>
                                                <a class="btn btn-default" href="{:U('control/member/groups?do=delete&id=' . $group['id'])}">删除</a>
                                            </div>
                                        </if>
                                    </td>
                                </tr>
                            </foreach>
                        </table>
                    </div>
                    <div class="form-group">
                        <input type="submit" name="batch" class="btn btn-primary" value="提交">
                        <a class="btn btn-default" href="{:U('control/member/groups?id=create')}">添加会员组</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <if condition="I('get.id') != ''">
        <div class="box col-md-12">
            <div class="box-inner">
                <div class="box-header well" data-original-title="">
                    <if condition="!empty($entity)">
                        <h2><i class="fa fa-edit"></i> 编辑会员组</h2>
                        <else/>
                        <h2><i class="fa fa-list"></i> 添加会员组</h2>
                    </if>
                </div>
                <div class="box-content">
                    <script>
                        require(['jquery', 'util'], function($, u){
                            $('#theform').submit(function(){
                                if($.trim($('input[name="title"]').val()) == '') {
                                    u.message('必须输入会员组名称');
                                    return false;
                                }
                            });
                        });
                    </script>
                    <form id="theform" action="" method="post" class="form-horizontal" group="form">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">会员组名称</label>
                            <div class="col-sm-4">
                                <input class="form-control" type="text" name="title" value="{$entity['title']}"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">说明</label>
                            <div class="col-sm-5">
                                <textarea name="remark" class="form-control" rows="4">{$entity['remark']}</textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-1">
                                <if condition="!empty($entity)">
                                    <button type="submit" class="btn btn-block btn-default">保存</button>
                                    <else/>
                                    <button type="submit" class="btn btn-block btn-default">新增</button>
                                </if>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </if>
</div>
<include file="Common/footer-control" />
